
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>look_picture</title>

<script src="http://libs.baidu.com/jquery/1.9.0/jquery.js"></script><script>
//指定部分内容打印
function doPrint() {
	debugger;
  var  bdhtml = window.document.body.innerHTML;
  var  sprnstr = "<!--startprint-->";    //用于截断字符串的内容，截取到指定的图片内容了
  var  eprnstr = "<!--endprint-->";
  var  prnhtml = bdhtml.substr(bdhtml.indexOf(sprnstr) + 17);
       prnhtml = prnhtml.substring(0, prnhtml.indexOf(eprnstr));
//       var printContent = $("#printConent")[0].innerHTML; //利用jquery获取打印内容;
//       window.document.body.innerHTML = printContent;
   window.document.body.innerHTML = prnhtml;
    if (getExplorer() == "IE") {
        pagesetup_null();
    }
    window.print();
    window.document.body.innerHTML=bdhtml; //还原 原有页面内容;
}

//获取浏览器类型
function getExplorer() {
    var explorer = window.navigator.userAgent;
    //ie
    if (explorer.indexOf("MSIE") >= 0) {
        return "IE";
    }
        //firefox
    else if (explorer.indexOf("Firefox") >= 0) {
        return "Firefox";
    }
        //Chrome
    else if (explorer.indexOf("Chrome") >= 0) {
        return "Chrome";
    }
        //Opera
    else if (explorer.indexOf("Opera") >= 0) {
        return "Opera";
    }
        //Safari
    else if (explorer.indexOf("Safari") >= 0) {
        return "Safari";
    }
}

//IE设置去除页眉页脚
function pagesetup_null() {
    var hkey_root, hkey_path, hkey_key;
    hkey_root = "HKEY_CURRENT_USER";
    hkey_path = "\\Software\\Microsoft\\Internet Explorer\\PageSetup\\";
    try {
        var RegWsh = new ActiveXObject("WScript.Shell");
        hkey_key = "header";
        RegWsh.RegWrite(hkey_root + hkey_path + hkey_key, "");
        hkey_key = "footer";
        RegWsh.RegWrite(hkey_root + hkey_path + hkey_key, "");
    } catch (e) { }
}
</script>

</head>
<body>
<center>
 <button onclick="doPrint()" >打印</button></br>
<!--   用于截断字符串的内容，截取到指定的图片内容了 -->
 <!--startprint-->
 	<center id="printConent" style="margin: auto">
      <img id="print" height="100%" width="100%" style="margin: auto" src="../../static/Upload_Files/{{ picture }}" />
    </center>
<!--endprint-->
 </center>
</body>
</html>